/*
 * Part of the ACID Project
 * Developed in 2011 by Morgan Taschuk
 */
package acid.spring.jdbc.services;

import acid.spring.GeneExpressionResultService;
import acid.spring.db.Experiment;
import acid.spring.db.ExperimentAnalysis;
import acid.spring.db.GeneAlias;
import acid.spring.db.GeneExpressionResult;
import acid.spring.db.Organism;
import acid.spring.db.Tissue;
import acid.spring.jdbc.repositories.GeneExpressionResultRepository;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author morgan
 */
@Service
public class JdbcGeneExpressionResultService implements GeneExpressionResultService
{

    @Autowired
    private GeneExpressionResultRepository geneExpressionResultRepository;


    @Override
    @Transactional
    public int createGeneExpressionResult(GeneAlias geneAlias,
            ExperimentAnalysis experimentAnalysis,
            Organism organism, Tissue tissue, double foldChange, double pVal)
    {
        GeneExpressionResult ger = new GeneExpressionResult(geneAlias,
                organism, tissue, foldChange, pVal, experimentAnalysis);
        return geneExpressionResultRepository.saveGeneExpressionResult(ger);
    }

    @Override
    @Transactional(readOnly=true)
    public List<GeneExpressionResult> queryByGeneAlias(GeneAlias geneAlias)
    {
        return geneExpressionResultRepository.queryByGeneAlias(geneAlias);
    }

    @Override
    @Transactional(readOnly=true)
    public List<GeneExpressionResult> queryByTissue(GeneAlias geneAlias, Tissue tissue)
    {
        return geneExpressionResultRepository.queryByTissue(geneAlias, tissue);
    }

    @Override
    public List<GeneExpressionResult> queryByExperiment(GeneAlias geneAlias, Experiment experiment)
    {
        return geneExpressionResultRepository.queryByExperiment(geneAlias, experiment);
    }



}
